<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>

<div class="block">
    
    <div class="block_head">
        <div class="bheadl"></div>
        <div class="bheadr"></div>
        
        <logic:lessThan name="userForm" property="userID" value="1">
            <h2>Add User</h2>
        </logic:lessThan>
        <logic:greaterThan name="userForm" property="userID" value="0">
            <h2>Edit User "<bean:write name="userForm" property="userName"/>"</h2>
        </logic:greaterThan>
        
    </div>
    <!-- .block_head ends -->
    
    <div class="block_content clearfix">
        <html:form styleId="userForm" action="admin/user.do" method="post">
            
            <logic:notEmpty name="errorMessages" >
                <div class="message errormsg">
                    <logic:iterate id="message" name="errorMessages">
                        <p><bean:write name="message"/></p>
                    </logic:iterate>
                </div>
            </logic:notEmpty>
            <logic:notEmpty name="successMessages" >
                <div class="message success">
                    <logic:iterate id="message" name="successMessages">
                        <p><bean:write name="message"/></p>
                    </logic:iterate>
                </div>
            </logic:notEmpty>
            
            <html:hidden property="userID" />
            <logic:notEmpty name="userForm" property="createdDate">
                <p><label>Joined On:</label>&nbsp;<span class="text"><fmt:formatDate type="date" value="${userForm.createdDate}"/></span></p>
            </logic:notEmpty>
            <p>
                <label for="userName">Username:</label><span class="required">*</span><br/>
                <html:text styleId="userName" styleClass="text required username" property="userName"/>
            </p>
            <p>
                <label for="email">Email:</label><span class="required">*</span><br/>
                <html:text styleId="email" styleClass="text medium required email" property="email"/>
            </p>
            <p>
                <label for="groupID">Group:</label><span class="required">*</span><br/>
                <html:select styleId="uf_groupID" property="groupID">
                    <option value="">-- Select --</option>
                    <logic:iterate id="group" name="groupList">
                        <html:option value="${group.groupID}">${group.groupName}</html:option>
                    </logic:iterate>
                </html:select>
                <label for="uf_groupID" class="error" generated="true" style="display:none;"></label>
            </p>
            
            <p>
                <label for="active">Active:</label><br/>
                <html:select property="active" styleClass="chzn-select">
                    <html:option value="0">Inactive</html:option>
                    <html:option value="1">Active</html:option>
                </html:select>
            </p>
            
            <p>
                <label for="password">Password:</label><span class="required">*</span><br/>
                <html:password styleClass="text required" property="password"/>
            </p>
            
            <p>
                <label for="fullName">Display Name:</label><span class="required">*</span><br/>
                <html:text styleClass="text required" property="fullName"/>
            </p>
            
            <p>
                <label for="gender">Gender:</label><br/>
                <html:select property="gender" styleClass="chzn-select">
                    <option value="">Not Telling</option>
                    <html:option value="1">Male</html:option>
                    <html:option value="0">Female</html:option>
                </html:select>
            </p>
            
            <hr/>
            
            <p>
                <html:submit property="action" value="Save" styleClass="submit small"/>
                <logic:greaterThan name="userForm" property="userID" value="0">
                    <html:link styleClass="confirm-button submit small red" action="/admin/userListing.do?action=delete" paramId="userID" paramName="userForm" paramProperty="userID">
                        Delete
                    </html:link>
                </logic:greaterThan>                
                <html:link action="/admin/userListing.do" styleClass="submit small gray">Cancel</html:link>
            </p>
            
            
        </div>
        <!-- .block_content ends -->
    </html:form>
        
    <div class="bendl"></div>
    <div class="bendr"></div>
    
</div>
<!-- .block ends -->
